package cn.seocoo.platform.web.controller.order;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.seocoo.platform.common.annotation.Log;
import cn.seocoo.platform.common.enums.BusinessType;
import cn.seocoo.platform.order.domain.AuthOrder;
import cn.seocoo.platform.order.service.IAuthOrderService;
import cn.seocoo.platform.common.core.controller.BaseController;
import cn.seocoo.platform.common.core.page.TableDataInfo;
import cn.seocoo.platform.common.core.domain.AjaxResult;
import cn.seocoo.platform.common.utils.poi.ExcelUtil;

/**
 * 认证缴费订单 信息操作处理
 * 
 * @author wujian
 * @date 2019-12-30
 */
@Controller
@RequestMapping("/order/authOrder")
public class AuthOrderController extends BaseController
{
    private String prefix = "order/authOrder";
	
	@Autowired
	private IAuthOrderService authOrderService;
	
	@RequiresPermissions("order:authOrder:view")
	@GetMapping()
	public String authOrder()
	{
	    return prefix + "/authOrder";
	}
	
	/**
	 * 查询认证缴费订单列表
	 */
	@RequiresPermissions("order:authOrder:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(AuthOrder authOrder)
	{
		startPage();
        List<AuthOrder> list = authOrderService.selectAuthOrderList(authOrder);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出认证缴费订单列表
	 */
	@RequiresPermissions("order:authOrder:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AuthOrder authOrder)
    {
    	List<AuthOrder> list = authOrderService.selectAuthOrderList(authOrder);
        ExcelUtil<AuthOrder> util = new ExcelUtil<AuthOrder>(AuthOrder.class);
        return util.exportExcel(list, "authOrder");
    }
	
	/**
	 * 新增认证缴费订单
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存认证缴费订单
	 */
	@RequiresPermissions("order:authOrder:add")
	@Log(title = "认证缴费订单", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(AuthOrder authOrder)
	{		
		return toAjax(authOrderService.insertAuthOrder(authOrder));
	}

	/**
	 * 修改认证缴费订单
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		AuthOrder authOrder = authOrderService.selectAuthOrderById(id);
		mmap.put("authOrder", authOrder);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存认证缴费订单
	 */
	@RequiresPermissions("order:authOrder:edit")
	@Log(title = "认证缴费订单", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(AuthOrder authOrder)
	{		
		return toAjax(authOrderService.updateAuthOrder(authOrder));
	}
	
	/**
	 * 删除认证缴费订单
	 */
	@RequiresPermissions("order:authOrder:remove")
	@Log(title = "认证缴费订单", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(authOrderService.deleteAuthOrderByIds(ids));
	}
	
}
